package com.huangmb.anymark.app.utils;

import com.amap.api.maps.model.LatLng;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.geocoder.*;
import com.huangmb.anymark.app.app.AnyMarkApplication;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/5/2 23:02
 */
public class GeoSearchUtils {

    /**
     * 根据坐标查询地理位置
     * @param latitude
     * @param longitude
     * @param listener onRegeocodeSearched 中i = 1000表示请求成功
     */
    public static void queryLocation(double latitude, double longitude, GeocodeSearch.OnGeocodeSearchListener listener){
        GeocodeSearch geocodeSearch = new GeocodeSearch(AnyMarkApplication.getInstance());
        geocodeSearch.setOnGeocodeSearchListener(listener);
        RegeocodeQuery query = new RegeocodeQuery(new LatLonPoint(latitude, longitude), 100, GeocodeSearch.AMAP);
        geocodeSearch.getFromLocationAsyn(query);
    }
    public static void queryLocation(LatLng point,GeocodeSearch.OnGeocodeSearchListener listener){
        queryLocation(point.latitude,point.longitude,listener);
    }
}
